// LanCan.cpp : Defines the entry point for the console application.
//
// Lab1.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <conio.h>
#include <vector>
#include "iostream"
using namespace std;
struct Edge
{
	int x;
	int y;
	int xet;
};
void main()
{
	vector<Edge> listEdge;
	vector<int> duongdi;
	freopen("input.txt", "rt", stdin);
	int n,m,tong;
	tong=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&m);
		tong=tong+m;
		int* a=new int[m];
		for(int j=0;j<=m;j++ )
		{
			scanf("%d",&a[j]);
		}
		for(int k=0;k<=m-1;k++)
		{
			Edge e;
			e.x=a[k];
			e.y=a[k+1];
			e.xet=0;
			listEdge.push_back(e);
		}
	}
	int d=listEdge[0].x;
	int c=listEdge[0].y;
 	//duongdi.push_back(c);
	int dem=0;
	int flag_=1;
	while(dem<tong)
	{
		int flag=0;
		for(int i=0;i<listEdge.size();i++)
		{
			if(listEdge[i].x==c && listEdge[i].xet==0)
			{
				duongdi.push_back(c);
				c=listEdge[i].y;
				listEdge[i].xet=1;
				flag=1;
				dem++;
			}
		}
		if(flag==0)
		{
			flag_=0;
			break;
		}
	}
	if(flag_==0)
		printf("%d",flag_);
	else
	{
		for(int i=0;i<duongdi.size();i++)
			printf("%d ",duongdi[i]);
		printf("%d",duongdi[0]);
	}
	
}

